#include <iostream>
using namespace std;

class Cperson
{
	public :
		int m_id;
		int m_age;
		int m_weight;

	public :
		Cperson(int id = 1, int age = 20, int weight = 55) :
			m_id(id), m_age(age), m_weight(weight)
		{
			cout << "<Cperson init()>" << endl;
		}

		Cperson(const Cperson& p) :
			m_id(p.m_id), m_age(p.m_age), m_weight(p.m_weight)
		{
			cout << "<Cperson copy()>" << endl;
		}

		Cperson& operator=(const Cperson& p)
		{
			if(this != &p)
			{
				m_id = p.m_id;
				m_age = p.m_age;
				m_weight = p.m_weight;
			}
			cout << "<Operator=()>" << endl;
			return *this;
		}

		Cperson operator+=(const Cperson& p)
		{
			cout << "<Operator+=()>" << endl;

			m_weight += p.m_weight;
			return *this;
		}

		Cperson operator-=(const Cperson& p)
		{
			cout << "<Operator-=()>" << endl;

			m_weight -= p.m_weight;
			return *this;
		}

		Cperson& operator++()
		{
			cout << "<Before Operator++()>" << endl;

			m_age++;
			m_weight++;
			return *this;
		}

		Cperson operator++(int)
		{
			cout << "<After Operator++()>" << endl;

			Cperson temp(*this);

			m_age++;
			m_weight++;
			return temp;
		}

		Cperson& operator--()
		{
			cout << "<Before Operator--()>" << endl;

			m_age--;
			m_weight--;
			return *this;
		}

		Cperson operator--(int)
		{
			cout << "<After Operator--()>" << endl;

			Cperson temp(*this);

			m_age--;
			m_weight--;
			return *this;
		}

		friend bool operator==(const Cperson& p1, const Cperson& p2);
		friend bool operator!=(const Cperson& p1, const Cperson& p2);
		friend istream& operator>>(istream& in, Cperson& p);
		friend ostream& operator<<(ostream& out, const Cperson& p);

	protected :
};

bool operator==(const Cperson& p1, const Cperson& p2)
{
	cout << "<Operator==()>" << endl;

	if(p1.m_id == p2.m_id && p1.m_age == p2.m_age && p1.m_weight == p2.m_weight)
	{
		return true;
	}
	else
	{
		return false;
	}
}

bool operator!=(const Cperson& p1, const Cperson& p2)
{
	cout << "<Operator!=()>" << endl;

	if(p1.m_id != p2.m_id || p1.m_age != p2.m_age || p1.m_weight != p2.m_weight)
	{
		return true;
	}
	else
	{
		return false;
	}
}

istream& operator>>(istream& in, Cperson& p)
{
	cout << "<重载输入函数，从键盘输入对应内容>" << endl;
	cout << "<My input()>" << endl;

	in >> p.m_id >> p.m_age >> p.m_weight;
	return in;
}

ostream& operator<<(ostream& out, const Cperson& p)
{
	out << "<My output()>" << endl << "Id     : " << p.m_id << endl << "Age    : " << p.m_age << endl << "Weight : " << p.m_weight;
	return out;
}

int main()
{
/*
	Cperson p1(1, 20, 75);
	Cperson p2(2, 21, 55);
*/
	
	Cperson p1;
	Cperson p2;
	cin >> p1;
	cin >> p2;

	Cperson p3;
	Cperson p4;

	bool b1;
	bool b2;

	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl;

	cout << "<重载输出函数，打印p1的内容>" << endl; 
	cout << p1 << endl;
	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl; 

	cout << "<重载输出函数，打印p2的内容>" << endl; 
	cout << p2 << endl;
	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl; 

	cout << "<重载关系运算符 == 、！=>" << endl; 
	b1 = p1 == p2;
	b2 = p1 != p2;
	cout << "Bool == : " << b1 << endl;
	cout << "Bool != : " << b2 << endl;
	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl; 

	cout << "<重载赋值运算符 = >" << endl; 
	p3 = p2;
	cout << p3 << endl;
	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl; 

	cout << "<重载复合赋值运算符 += >" << endl; 
	p1 += p2;
	cout << p1 << endl;
	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl; 

	cout << "<重载复合赋值运算符 -= >" << endl; 
	p1 -= p2;
	cout << p1 << endl;
	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl; 

	cout << "<重载自增运算符 ++ >" << endl; 
	cout << p1 << endl << endl;
	cout << "******************************************************" << endl; 

	p4 = ++p1;
	cout << "<p4 = ++p1> : " << endl << "Age++    : " << p4.m_age << endl << "Weight++ : " << p4.m_weight << endl << endl;
	cout << "******************************************************" << endl; 

	p4 = p1++;
	cout << "<p4 = ++p1> : " << endl << "Age++    : " << p4.m_age << endl << "Weight++ : " << p4.m_weight << endl << endl;
	cout << "******************************************************" << endl; 

	cout << "<p1++>      : " << endl << p1++ << endl << endl;
	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl; 

	cout << "<重载自减运算符 -- >" << endl; 
	cout << p1 << endl << endl;
	cout << "******************************************************" << endl; 

	p4 = --p1;
	cout << "<p4 = --p1> : " << endl << "Age--    : " << p4.m_age << endl << "Weight-- : " << p4.m_weight << endl << endl;
	cout << "******************************************************" << endl; 

	p4 = p1--;
	cout << "<p4 = --p1> : " << endl << "Age--    : " << p4.m_age << endl << "Weight-- : " << p4.m_weight << endl << endl;
	cout << "******************************************************" << endl; 

	cout << "<p1-->      : " << endl << p1-- << endl << endl;
	cout << "******************************************************" << endl; 
	cout << "******************************************************" << endl; 
}
